package models

import (
	"time"

	"github.com/beego/beego/v2/client/orm"
	_ "github.com/go-sql-driver/mysql"
)

type Order struct {
	Id         int       `orm:"column(id);auto"`
	User       string    `orm:"column(user);size(255)"`
	CreateTime time.Time `orm:"column(create_time);type(datetime)"`
	StartTime  time.Time `orm:"column(start_time);type(datetime);null"`
	EndTime    time.Time `orm:"column(end_time);type(datetime);null"`
	Status     string    `orm:"column(status);size(255);description(waiting, underway, canceled, finished)"`
	TaxiId     int       `orm:"column(taxi_id);null"`
}

type Taxi struct {
	Id         int    `orm:"column(id);auto"`
	Status     string `orm:"column(status);size(255);description(waiting, busy)"`
	Driver     string `orm:"column(driver);size(255)"`
	OrderCount int    `orm:"column(order_count);default(0)"`
}

func Register() {
	orm.RegisterModel(new(Order), new(Taxi))
	orm.RegisterDriver("mysql", orm.DRMySQL)
	orm.RegisterDataBase("default", "mysql", "root:J0rKiZqCClO5HGRF@tcp(127.0.0.1:3306)/dispatch_system?charset=utf8mb4&parseTime=True&loc=Local")
}
